# Contributor: Galen Abell <galen@galenabell.com>
# Maintainer: Galen Abell <galen@galenabell.com>
pkgname=k9s
_pkgname=github.com/derailed/k9s
pkgver=0.25.21
pkgrel=0
pkgdesc="Kubernetes TUI"
url="https://k9scli.io"
# riscv64 FTBS
arch="all !x86 !armhf !riscv64 !aarch64" # tests fail
license="Apache-2.0"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"
options="net chmod-clean"
source="$pkgname-$pkgver.tar.gz::https://github.com/derailed/k9s/archive/v$pkgver.tar.gz"

export GOPATH="$srcdir/go"
export GOCACHE="$srcdir/go-build"
export GOTMPDIR="$srcdir"

build() {
	local ldflags="
	-X $_pkgname/cmd.version=$pkgver
	-X $_pkgname/cmd.commit=AlpineLinux
	-X $_pkgname/cmd.date=$(date +%FT%T%Z)
	"
	go build -ldflags "$ldflags" -tags netgo -o execs/$pkgname

	./execs/k9s completion bash >k9s.bash
	./execs/k9s completion zsh >k9s.zsh
	./execs/k9s completion fish >k9s.fish
}

check() {
	go test ./...
}

package() {
	install -Dm755 execs/$pkgname "$pkgdir"/usr/bin/$pkgname

	install -Dm644 k9s.bash \
		"$pkgdir"/usr/share/bash-completion/completions/k9s
	install -Dm644 k9s.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_k9s
	install -Dm644 k9s.fish \
		"$pkgdir"/usr/share/fish/completions/k9s.fish
}

sha512sums="
3d9d0a45d36e98122b063af633d98a70cdb3f6d3da66606cb9b1214ea6fc552f0b13c1f54208f45db621432b95cf93fc51b90a5d6171edcc0f4b9a84f4d80a9a  k9s-0.25.21.tar.gz
"
